<?php
namespace app\models;
use common\component\tool\Tool;
use app\models\Basic;

use Yii;

class DynamicDataFlag extends Basic
{
    
    public static function tableName()
    {
        return '{{%dynamic_data_flag}}';
    }

    public function rules()
    {
        return [
            ['dynamic_id', 'required', 'message' => 'dynamic_id不能为空'],
            ['dynamic_id', 'integer', 'message' => 'dynamic_id必须为数字，或数字字符串', 
                        'min'=>0, 'tooSmall' => 'dynamic_id最小存储0', 
                        'max'=>18446744073709551615, 'tooBig' => 'dynamic_id最大存储18446744073709551615'],
            ['flagname', 'required', 'message' => 'flagname不能为空', 'on' => 'add'],
            ['flagname', 'string', 'message' => 'flagname必须是字符串',
                        'min' => 1, 'tooShort' => 'flagname最短1位',
                        'max' => 128, 'tooLong' => 'flagname最长128位'],
        ];
    }


    /*添加*/
    public function addDynamicDataFlag($data, $dynamic_id)
    {
        $data['DynamicDataFlag']['dynamic_id'] = $dynamic_id;
        // P($data);

        if($this->load($data) and $this->validate()){
            // P($this);
            if($this->save(false)){
                return true;
            }
        }
        return false;
    }

    
}